<template>
	<view class="video-list g-container">
		<list class="g-queue" show-scrollbar="false" enableBackToTop="true" scroll-y loadmoreoffset="15">
			<cell @tap="toPlay(index)" class="video-page-card g-item" v-if="(index+1)%2==1" v-for="(item,index) in videoList"
			 :key="index">
				<image class="img-bg" lazy-load :src="formatUrl(item.img)" mode="widthFix"></image>
				<view class="tips" v-if="item.state==0">
					<text style="color: #ffffff;">
						审核中
					</text>
				</view>
				<view class="tips" v-if="item.state==2">
					<text style="color: #FF0000;">
						审核未通过
					</text>
				</view>
				<view class="video-footer">
					<text class="video-page-title">{{item.title}}</text>
					<view class="user-wrap">
						<view class="user-info">
							<image class="user-head" lazy-load :src="formatUrl(item.head_img)" mode="aspectFill"></image>
							<text>{{item.name}}</text>
						</view>
						<view class="skr-info">
							<image class="skr-icon" src="/static/home/heart.png" mode=""></image>
							<text>{{item.skr_count}}</text>
						</view>
					</view>
				</view>
			</cell>
		</list>
		<list class="g-queue" show-scrollbar="false">
			<cell @tap="toPlay(index)" class="video-page-card g-item" v-if="(index+1)%2==0" v-for="(item,index) in videoList"
			 :key="index">
				<image class="img-bg" lazy-load :src="formatUrl(item.img)" mode="widthFix"></image>
				<view class="tips" v-if="item.state==0">
					<text style="color: #ffffff;">
						审核中
					</text>
				</view>
				<view class="tips" v-if="item.state==2">
					<text style="color: #FF0000;">
						审核未通过
					</text>
				</view>
				<view class="video-footer">
					<text class="video-page-title">{{item.title}}</text>
					<view class="user-wrap">
						<view class="user-info">
							<image class="user-head" lazy-load :src="formatUrl(item.head_img)" mode="aspectFill"></image>
							<text>{{item.name}}</text>
						</view>
						<view class="skr-info">
							<image class="skr-icon" src="/static/home/heart.png" mode=""></image>
							<text>{{item.skr_count}}</text>
						</view>
					</view>
				</view>
			</cell>
		</list>
	</view>
</template>

<script>
	export default {
		props: {
			videoList: {
				type: [Array, Object],
				default: () => {}
			},
			page: {
				type: Number,
				default: 1
			},
			type: {
				type: String,
				default: "hot"
			}
		},
		methods: {
			//格式化链接地址
			formatUrl(url1) {
				if (url1 == undefined) {
					return;
				}
				var index = url1.indexOf("http");
				if (index == 0) {
					return url1;
				}
				return this.$store.state.baseUrl + url1;
			},
			toPlay(index) {
				this.$store.commit("setVideoList", this.videoList.slice(index, this.videoList.length));
				uni.navigateTo({
					url: '/pages/video/index?index=0' + '&type=' +
						this.type + '&page=' + this.page
				});
			},
			loadmore() {
				uni.$emit("loadMore", {})
			}
		}
	}
</script>

<style lang="scss">
	$lineCount: 2;

	.g-container {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		overflow: hidden;
	}

	.g-queue {
		display: flex;
		flex-direction: column;
		flex-basis: 50%;
		margin-right: 2%;
	}

	.g-item {
		position: relative;
		width: 100%;
		margin-top: 2%;
		padding-right: 12rpx;
	}

	.video-list {
		margin-left: 2%;
		margin-top: 2%;
	}

	.videolist {
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;

		.videoitem {
			width: 50%;
		}
	}

	.tips {
		position: absolute;
		top: 0;
		left: 0;
		display: flex;
		justify-content: center;
		align-items: center;
		border-radius: 12rpx;
		bottom: 12rpx;
		text-align: center;
		background-color: rgba(0, 0, 0, .6);
		padding-top: 5rpx;
		padding-bottom: 5rpx;
		right: 12rpx;
	}

	.video-page-title {
		padding: 0 12rpx;
		flex-wrap: nowrap;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		lines: 1;
	}

	/**
	 * 视频卡片开始
	 */
	.video-page-card {

		position: relative;
		width: 100%;
		transition: opacity .4s ease-in-out; // 检索或设置对象变换时的过渡

		.img-bg {
			background-color: white;
			border-radius: 12rpx;
			width: 100% !important;
		}

		.video-footer {
			padding: 10rpx;
			font-size: $uni-font-size-sm;
			height: 100rpx;
			width: 100%;
			display: flex;
			flex-direction: column;
			position: absolute;
			bottom: 0;
			color: $uni-text-color-inverse;
			font-family: PingFang SC;

			.user-wrap {
				margin-top: 10rpx;
				display: flex;
				flex-direction: row;

				.user-info {
					flex: 7;
					display: flex;
					flex-direction: row;
					align-items: center;

					.user-head {
						border-radius: 50%;
						width: 48rpx !important;
						height: 48rpx;
					}

					text {
						font-size: 18rpx;
						margin-left: 10rpx;
					}

				}

				.skr-info {
					flex: 3;
					flex-shrink: 0;
					align-items: center;
					display: flex;
					flex-direction: row;

					image {
						width: 24rpx !important;
						height: 24rpx;
					}

					text {
						font-size: 18rpx;
						margin-left: 10rpx;
					}
				}
			}

		}
	}
</style>
